package com.marvels.financial.collection.controller;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.fintech.third.service.shzx.ShangHaiLogInService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import com.marvels.common.dto.MarvelsResultDTO;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.exception.MarvelsErrorCode;
import com.marvels.common.utils.MarvelsLogUtil;
import com.marvels.dubbo.externalservice.service.SendSmsService;
import com.marvels.financial.collection.dto.CaseInfoDTO;
import com.marvels.financial.collection.dto.CollectAccountDTO;
import com.marvels.financial.collection.dto.CollectCommonModularInfoDTO;
import com.marvels.financial.collection.dto.CollectListConditionDTO;
import com.marvels.financial.collection.dto.CollectListInfoDTO;
import com.marvels.financial.collection.dto.CollectTransferDTO;
import com.marvels.financial.collection.dto.CommonConditionDTO;
import com.marvels.financial.collection.dto.McfeCollecteActionRecordDTO;
import com.marvels.financial.collection.dto.McfeOverdueCollectionCollectionVisitDTO;
import com.marvels.financial.collection.dto.McfeOverdueCollectionVerificationDTO;
import com.marvels.financial.collection.dto.OnlineDeductionDto;
import com.marvels.financial.collection.dto.OverDueTransInfoDTO;
import com.marvels.financial.collection.service.CollectManageApi;
import com.marvels.financial.collection.service.CollectManageService;
import com.marvels.financial.loan.dto.McfeCustomerLoanContractDTO;
import com.marvels.financial.loan.dto.McfeCustomerRepaymentPlanDTO;
import com.marvels.financial.loan.service.ShzxDeleteDataJobApi;
import com.marvels.financial.loan.service.ShzxInterfaceSendJobApi;
import com.marvels.system.permission.dto.SysRoleDTO;
import com.marvels.system.permission.dto.SysUserDTO;
import com.marvels.system.permission.service.SysRoleService;


/**
 * 催收管理
 * @author tangpw
 *
 */
@RequestMapping("financial/collection/manage/service")
@RestController
public class CollectManageController {
	
	@Autowired
	private CollectManageApi collectManageApi;
	@Autowired
	private CollectManageService collectManageService;
	@Autowired
	private SysRoleService sysRoleService;
	@InitBinder
	public void initBinder(WebDataBinder binder) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
		dateFormat.setLenient(false);
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
	}
	
	/**
	 * 催收初始化条件
	 * @return
	 */
	@RequestMapping("collectCondition")
	@ResponseBody
	public MarvelsResultDTO collectCondition(){
		try {
			return collectManageApi.collectCondition();
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收初始化条件查询FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收初始化条件查询异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "催收初始化条件查询异常", null);
		}
	}
	
	
	
	
	/**
	 * 催收列表
	 * @return
	 */
	@RequestMapping("collectList")
	@ResponseBody
	public MarvelsResultDTO collectList(@RequestBody CollectListConditionDTO condition){
		try {
			Map<String, Object> data = collectManageApi.collectList(condition);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), data);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收列表查询FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收列表查询异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "催收列表查询异常", null);
		}
	}
	
	/**
	 * 线上代扣列表
	 * @param loanIds
	 * @return
	 */
	@RequestMapping("onlineDeductionList")
	@ResponseBody
	public MarvelsResultDTO onlineDeductionList(@RequestBody Map<String, String> param){
		try {
			String loanIds = param.get("loanIds");
			String channel = param.get("channel");
			List<OnlineDeductionDto> list=collectManageApi.onlineDeductionList(loanIds, channel);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>线上代扣列表FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>线上代扣列表异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "线上代扣列表异常", null);
		}
	}
	
	/**
	 * 更新催收处理时间
	 * @param dto
	 * @return
	 */
	@RequestMapping("updateCollecteDate")
	@ResponseBody
	public MarvelsResultDTO updateCollecteDate(@RequestBody CollectListConditionDTO condition){
		try {
			collectManageApi.updateCollecteDate(condition);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), null);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>更新催收处理时间FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>更新催收处理时间异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "更新催收处理时间异常", null);
		}
	}
	
	/**
	 * 催收转派列表
	 * @return
	 */
	@RequestMapping("collectTransferList")
	@ResponseBody
	public MarvelsResultDTO collectTransferList(@RequestBody CollectListConditionDTO condition){
		try {
			Map<String, Object> data = collectManageApi.collectTransferList(condition);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), data);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收转派列表查询FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收转派列表查询异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "催收转派列表查询异常", null);
		}
	}
	
	/**
	 * 查询催收角色的用户
	 * @param condition
	 * @return
	 */
	@RequestMapping("collectUserList")
	@ResponseBody
	public MarvelsResultDTO collectUserList(){
		try {
			List<SysUserDTO> sysUserList = new ArrayList<SysUserDTO>();
			List<String> roleCodes = new ArrayList<String>();
			roleCodes.add("CS01");
			List<SysRoleDTO> roleList = sysRoleService.getSysRolesByRoleCodes(roleCodes);
			if(roleList != null && roleList.size() > 0){
				sysUserList = roleList.get(0).getSysUsers();
			}
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), sysUserList);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询催收角色的用户FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询催收角色的用户异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "查询催收角色的用户异常", null);
		}
	}
	
	/**
	 * 保存转派信息
	 * @return
	 */
	@RequestMapping("saveTransferInfo")
	@ResponseBody
	public MarvelsResultDTO saveTransferInfo(@RequestBody CollectTransferDTO collectTransferDTO){
		try {
			collectManageApi.saveTransferInfo(collectTransferDTO);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), null);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>保存转派信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>保存转派信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "保存转派信息异常", null);
		}
	}
	
	
	/**
	 * excel下载
	 * @param condition
	 * @param request
	 * @param response
	 */
	@RequestMapping("exdownLoadExcel")
	public void downLoadExcel(CollectListConditionDTO condition,HttpServletRequest request,HttpServletResponse response) {
		response.setCharacterEncoding("UTF-8");
		response.setContentType("application/vnd.ms-excel");
		OutputStream outs = null;
		try {
			response.setHeader("Content-disposition", "attachment; filename="+ new String("总数据查询.xls".getBytes("UTF-8"),"ISO8859-1"));
			HSSFWorkbook downLoadDeal2 = collectManageApi.downLoadExcel(condition);
			outs = response.getOutputStream();// 获取文件输出IO流
			downLoadDeal2.write(outs);
		}catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>excel下载数据", e);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>excel下载数据", e);
		}finally{
			try {
				outs.close();
			} catch (Exception e2) {
				// TODO: handle exception
			}
			
		}
	}
	
	
	
	/**
	 * 线下委外excel下载
	 * @param condition
	 * @param request
	 * @param response
	 */
	@RequestMapping("downOutsideExcel")
	public void downOutsideExcel(CollectListConditionDTO condition,HttpServletRequest request,HttpServletResponse response) {
		response.setCharacterEncoding("UTF-8");
		response.setContentType("application/vnd.ms-excel");
		OutputStream outs = null;
		try {
			response.setHeader("Content-disposition", "attachment; filename="+ new String("委外总数据查询.xls".getBytes("UTF-8"),"ISO8859-1"));
			HSSFWorkbook downLoadDeal2 = collectManageService.downOutsideExcel(condition);
			outs = response.getOutputStream();// 获取文件输出IO流
			downLoadDeal2.write(outs);
		}catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>excel下载数据", e);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>excel下载数据", e);
		}finally{
			try {
				outs.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	
	
	
	
	
	/**
	 * 催收公共模块信息
	 * @return
	 */
	@RequestMapping("commonModularInfo")
	@ResponseBody
	public MarvelsResultDTO commonModularInfo(@RequestBody CollectListConditionDTO condition){
		try {
			CollectCommonModularInfoDTO dto= collectManageApi.commonModularInfo(condition);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), dto);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收初始化条件查询FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收初始化条件查询异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "催收初始化条件查询异常", null);
		}
	}
	
	
	/**
	 * 新增行动信息
	 * @return
	 */
	@RequestMapping("addActionInfo")
	@ResponseBody
	public MarvelsResultDTO addActionInfo(@RequestBody McfeCollecteActionRecordDTO dto){
		try {
			collectManageApi.addActionInfo(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), null);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增行动信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增行动信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增行动信息异常", null);
		}
	}
	
	
	
	
	/**
	 * 新增电催信息
	 * @return
	 */
	@RequestMapping("addElectricCollectInfo")
	@ResponseBody
	public MarvelsResultDTO addElectricCollectInfo(@RequestBody McfeOverdueCollectionVerificationDTO dto){
		try {
			collectManageApi.addElectricCollectInfo(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), null);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增电催信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增电催信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增电催信息异常", null);
		}
	}
	
	
	
	
	/**
	 * 修改电催信息
	 * @return
	 */
	@RequestMapping("modifyElectricCollectInfo")
	@ResponseBody
	public MarvelsResultDTO modifyElectricCollectInfo(@RequestBody McfeOverdueCollectionVerificationDTO dto){
		try {
			collectManageApi.modifyElectricCollectInfo(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), null);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>修改电催信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>修改电催信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增电催信息异常", null);
		}
	}
	
	
	
	/**
	 * 新增催收外访
	 * @return
	 */
	@RequestMapping("addCollectVisitInfo")
	@ResponseBody
	public MarvelsResultDTO addCollectVisitInfo(@RequestBody McfeOverdueCollectionCollectionVisitDTO dto){
		try {
			collectManageApi.addCollectVisitInfo(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), null);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增催收外访FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增催收外访异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增催收外访异常", null);
		}
	}
	
	
	
	
	/**
	 * 上传催收外访
	 * @return
	 */
	@RequestMapping("uploadCollectVisitInfo")
	@ResponseBody
	public MarvelsResultDTO uploadCollectVisitInfo(McfeOverdueCollectionCollectionVisitDTO dto){
		try {
			return collectManageApi.uploadCollectVisitInfo(dto);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>上传催收外访FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>上传催收外访异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增催收外访异常", null);
		}
	}
	
	
	/**
	 * 下载催收外访文件
	 * @param dto
	 * @param request
	 * @param response
	 */
	@RequestMapping("downLoadVisitFile")
	public void downLoadVisitFile(McfeOverdueCollectionCollectionVisitDTO dto,HttpServletRequest request,HttpServletResponse response) {
		OutputStream outs = null;
		try {
			
			byte[] batchByte = collectManageApi.downLoadVisitFile(dto);
			response.setCharacterEncoding("UTF-8");
			response.setContentType("application/x-download;charset=utf-8");// 设置response内容的类型
			if (batchByte.length > 0) {
				response.setHeader("Content-disposition",
						"attachment;filename=" + new String(dto.getFileName().getBytes(), "ISO8859-1"));// 设置头部信息
				outs = response.getOutputStream();// 获取文件输出IO流
				BufferedOutputStream bouts = new BufferedOutputStream(outs);
				bouts.write(batchByte);
				bouts.flush();// 这里一定要调用flush()方法
				bouts.close();
				outs.close();
			} else {
				response.setHeader("Content-disposition", "attachment;filename=信息未找到.txt");
				response.getWriter().print("未找到数据，请确认！");
			}
		} catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>下载出错了！", e);
			response.setHeader("Content-disposition", "attachment;filename=信息未找到.txt");
			try {
				response.getWriter().print("下载异常！");
			} catch (IOException e1) {
				MarvelsLogUtil.getInstance().error("下载异常", e);
			}
		}finally {
			try {
				outs.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	/**
	 * 查询基础信息
	 * @param loanId
	 * @return
	 */
	@RequestMapping("selectBasicInfo")
	@ResponseBody
	public MarvelsResultDTO selectBasicInfo(@RequestBody CollectListConditionDTO coditionDto){
		try {
			Map<String,Object> basicInfo = collectManageApi.selectBasicInfo(coditionDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), basicInfo);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收管理查询基础信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收管理查询基础信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "催收管理查询基础信息异常", null);
		}
	}
	
	
	/**
	 * 逾期短信提醒
	 * @param coditionDto
	 * @return
	 */
	@RequestMapping("overdueSMSReminder")
	@ResponseBody
	public MarvelsResultDTO overdueSMSReminder(@RequestBody String loanIds){
		try {
			collectManageApi.overdueSmsReminder(loanIds);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), null);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>逾期短信提醒FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>逾期短信提醒异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "逾期短信提醒异常", null);
		}
	}
	
	
	/**
	 * 查询融资账户信息
	 * @param loanId
	 * @return
	 */
	@RequestMapping("selectAccountInfo")
	@ResponseBody
	public MarvelsResultDTO selectAccountInfo(@RequestBody CollectListConditionDTO coditionDto){
		try {
			CollectAccountDTO accountInfo = collectManageApi.selectAccountInfo(coditionDto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), accountInfo);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收管理查询融资账户信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>催收管理查询融资账户信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "催收管理查询融资账户信息异常", null);
		}
	}
	/**
	 * 查询金融信息列表
	 * @param coditionDto
	 * @return
	 */
	@ResponseBody
	@RequestMapping("selectTransList")
	public MarvelsResultDTO selectTransList(@RequestBody CollectListConditionDTO coditionDto){
		PageInfo<OverDueTransInfoDTO> pageInfo = null;
		try {
			pageInfo = collectManageApi.selectTransList(coditionDto);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询催收客户的金融信息列表FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询催收客户的金融信息列表异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "查询催收客户的金融信息查询异常", null);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), pageInfo);
	}
	/**
	 * 查看交费金融信息详情
	 * @param id
	 * @return
	 */
	@ResponseBody
	@RequestMapping("selectTransInfoDetail")
	public MarvelsResultDTO selectTransInfoDetail(@RequestBody CollectListConditionDTO coditionDto){
		OverDueTransInfoDTO transInfo = null;
		try {
			transInfo = collectManageApi.selectTransInfoDetail(coditionDto.getId());
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询催收客户的金融信息详情FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch(Exception e){
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询催收客户的金融信息详情异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "查询催收客户的金融信息详情异常", null);
		}
		return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), transInfo);
	}
	
	
	/**
	 * 行动信息查询
	 * @return
	 */
	@RequestMapping("actionInfoList")
	@ResponseBody
	public MarvelsResultDTO actionInfoList(@RequestBody McfeCollecteActionRecordDTO dto){
		try {
			List<McfeCollecteActionRecordDTO> list=collectManageApi.actionInfoList(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增行动信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>新增行动信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增行动信息异常", null);
		}
	}
	
	
	
	
	/**
	 * 案件信息
	 * @return
	 */
	@RequestMapping("caseInfo")
	@ResponseBody
	public MarvelsResultDTO caseInfo(@RequestBody CaseInfoDTO dto){
		try {
			CaseInfoDTO caseInfo=collectManageApi.caseInfo(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), caseInfo);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询案件信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询案件信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增行动信息异常", null);
		}
	}
	
	
	
	
	/**
	 * 查询融资合同信息
	 * @return
	 */
	@RequestMapping("financingContract")
	@ResponseBody
	public MarvelsResultDTO financingContract(@RequestBody CommonConditionDTO dto){
		try {
			Page<McfeCustomerLoanContractDTO> contractDTO=collectManageApi.financingContract(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), contractDTO);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询融资合同信息FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询融资合同信息异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增行动信息异常", null);
		}
	}
	
	
	
	
	/**
	 * 还款计划分页
	 * @return
	 */
	@RequestMapping("planList")
	@ResponseBody
	public MarvelsResultDTO planList(@RequestBody CommonConditionDTO dto){
		try {
			Page<McfeCustomerRepaymentPlanDTO> list=collectManageApi.planList(dto);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.SUCCESS.getValue(), MarvelsErrorCode.SUCCESS.getDesc(), list);
		} catch (MarvelsBusinessException e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询还款计划分页FAIL:", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.FAIL.getValue(), e.getMessage(), null);
		}catch (Exception e) {
			MarvelsLogUtil.getInstance().error(">>>>>>>>>查询还款计划分页异常", e);
			return MarvelsResultDTO.getResult(MarvelsErrorCode.ERROR.getValue(), "新增行动信息异常", null);
		}
	}
}
